package com.woniuxy.sensitive.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.sensitive.entity.SensitiveWords;
import com.woniuxy.sensitive.mapper.SensitiveWordsMapper;
import com.woniuxy.sensitive.service.DBSensitiveWordsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class DBSensitiveWordsServiceImpl extends ServiceImpl<SensitiveWordsMapper, SensitiveWords>
        implements DBSensitiveWordsService {

    @Override
    public List<String> getAllWords() {
        return list().stream()
                .filter(word -> word.getStatus() == 1) // 只取启用的敏感词
                .map(SensitiveWords::getWord)
                .collect(Collectors.toList());
    }
}
